<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue练习</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
    <div id="app">
        {{message}}
        <input v-model="message">
    </div>

    <div id="app2">
        <span v-bind:title="message">
            鼠标悬停几秒钟查看此处动态绑定的提示信息！
        </span>
    </div>

    <div id="app3">
        <p v-if="seen">能看见我么</p>
    </div>

    <div id="app4">
        <ol>
            <li v-for="todo in todos">
                {{todo.text}}/{{todo.message}}
            </li>
        </ol>
    </div>

    <div id="app5">
        <p>{{ message }}</p>
        <button v-on:click="reverseMessage">逆转消息</button>
    </div>

    <div id="app6">
        <data-item
            v-for="item in dataList"
            v-bind:data="item"
            v-bind:key="item.id">

        </data-item>
    </div>
</body>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            message:"Hello Vue!"
        }
    });

    var app2 = new Vue({
        el:"#app2",
        data: {
            message: '页面加载于 ' + new Date().toLocaleString()
        }
    });

    var app3 = new Vue({
        el:"#app3",
        data:{
            seen:true
        }
    });

    var app4 = new Vue({
        el:"#app4",
        data:{
            todos:[
                {text:"1",message:"m1"},
                {text:"2",message:"m2"},
                {text:"3",message:"m3"}
            ]
        }
    });

    var app5 = new Vue({
        el: '#app-5',
        data: {
            message: 'Hello Vue.js!'
        },
        methods: {
            reverseMessage: function () {
                this.message = this.message.split('').reverse().join('')
            }
        }
    });

    Vue.component('data-item',{
        props:['data'],
        template:"<li>{{data.id}}/{{data.text}}</li>"
    });
    var app6 = new Vue({
        el:"#app6",
        data:{
            dataList:[
                {id:1,text:'aa'},
                {id:2,text:'bb'},
                {id:3,text:'cc'}
            ]
        }
    });
</script>
</html>